module Page4.Model exposing (..)
import Json.Decode as D

type alias Page = 
  {title: String
  ,skills: List Skill}

type alias Skill =
  {title: String
  ,items: List Item}

type alias Item = 
  {name: String
  ,star: Int}

decoder: D.Decoder Page
decoder =
  D.map2 Page
    (D.field "title" D.string)
    (D.field "skills" (D.list skill_decoder))

skill_decoder: D.Decoder Skill
skill_decoder = 
  D.map2 Skill
    (D.field "title" D.string)
    (D.field "items" (D.list item_decoder))

item_decoder: D.Decoder Item
item_decoder =
  D.map2 Item
    (D.field "name" D.string)
    (D.field "star" D.int)